using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using Rifts.Models.Characters;
using Rifts.Controls;

namespace Rifts
{
	public class CharacterSheetPaginator : DocumentPaginator
	{
		readonly Character m_Character;

		public CharacterSheetPaginator(Character character, Size pageSize)
		{
			PageSize = pageSize;
			m_Character = character;
		}

		public override DocumentPage GetPage(int pageNumber)
		{
			var myPanel = new Border();
			myPanel.MaxHeight = PageSize.Height;
			myPanel.MaxWidth = PageSize.Width;
			myPanel.DataContext = m_Character;
			myPanel.Padding = new Thickness(96 * 0.25); // 1/4" border

			switch (pageNumber)
			{
				case 0:
					myPanel.Child = new CharacterSheetPage1();
					break;
				case 1:
					myPanel.Child = new CharacterSheetPage2();
					break;
			}


			myPanel.Measure(PageSize);
			myPanel.Arrange(new Rect(new Point(0, 0), myPanel.DesiredSize));
			myPanel.UpdateLayout();

			return new DocumentPage(myPanel);
		}

		public override bool IsPageCountValid
		{
			get { return true; }
		}

		public override int PageCount
		{
			get { return 2; }
		}

		public override Size PageSize { get; set; }

		public override IDocumentPaginatorSource Source
		{
			get { return null; }
		}
	}
}
